package com.lufei.network.faceLogin;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.lufei.network.R;
import com.lufei.network.base.BaseActivity;
import com.lufei.network.faceLogin.Bean.Users;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;

/**
 * @作者 liushijiang
 * @创建日期 2020/4/9 16:46
 * @描述 $暂无$注册
 */

public class RegisteredActivity extends BaseActivity {
    @BindView(R.id.ed_phone_number)
    EditText edPhoneNumber;
    @BindView(R.id.ed_password)
    EditText edPassword;
    @BindView(R.id.btn_registered)
    Button btnRegistered;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_registere);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.ed_phone_number, R.id.ed_password, R.id.btn_registered})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ed_phone_number:
                break;
            case R.id.ed_password:
                break;
            case R.id.btn_registered:
                register();
                break;
        }
    }
    private void register(){
        Users p2 = new Users();
        p2.setPhone(edPhoneNumber.getText().toString().trim());
        p2.setPassword(edPassword.getText().toString().trim());
        p2.save(new SaveListener<String>() {
            @Override
            public void done(String objectId, BmobException e) {
                if(e==null){
                    Toast.makeText(RegisteredActivity.this, "添加数据成功，返回objectId为："+objectId, Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(RegisteredActivity.this, "创建数据失败：" + e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}
